local wu__qiexi = fk.CreateSkill {
  name = "wu__qiexi",
}

Fk:loadTranslationTable{
  ["wu__qiexi"] = "窃习",
  [":wu__qiexi"] = "结束阶段，你可以将最后的手牌当【顺手牵羊】使用。",
  ["#wu__qiexi"] = "窃习：你可以将最后的手牌当【顺手牵羊】使用",
}

wu__qiexi:addEffect(fk.EventPhaseStart, {
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(wu__qiexi.name) and player.phase == Player.Finish and player:getHandcardNum() == 1
  end,

  on_cost = function(self, event, target, player, data)
    local room = player.room
    local use = room:askToUseVirtualCard(player, {
      name = "snatch",
      skill_name = wu__qiexi.name,
      prompt = "#wu__qiexi",
      cancelable = true,
      extra_data = {
        bypass_times = true,
        extraUse = true,
      },
      card_filter = {
        n = 1,
        cards = player:getHandlyIds(),
      },
      skip = true,
    })
    if use then
      event:setCostData(self, {extra_data = use})
      return true
    end
  end,

  on_use = function(self, event, target, player, data)
    local room = player.room
    room:useCard(event:getCostData(self).extra_data)
  end,
})

return wu__qiexi